package cn.drew.basic.utils.redisUtils;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedisPool;

import java.util.ArrayList;
import java.util.List;

@Service
public class RedisBean {

    @Bean
    public ShardedJedisPool createShardedJedisPool(){
        JedisPoolConfig poolConfig=new JedisPoolConfig();
        poolConfig.setMinIdle(2);
        poolConfig.setMaxTotal(10);
        List<JedisShardInfo> list=new ArrayList<>();
        list.add(new JedisShardInfo("127.0.0.1","6379"));
        return new ShardedJedisPool(poolConfig,list);
    }
}
